import java.lang.reflect.Field;

public class ClassUser {
    public static void main(String[] args) throws ClassNotFoundException, InstantiationException, IllegalAccessException, NoSuchFieldException {
        //获得class对象
        Person person = new Person();
        Class<? extends Person> c1 = person.getClass();
        System.out.println(c1);//测试存在


        Field name = c1.getField("name");
        name.set(person,"cx");
        System.out.println(name.get(person));

        System.out.println(person.name);

    }
}
